{ "cells": [ { "cell_type": "markdown", "id": "de7e614b", "metadata": {}, "source": [ "# Orbital Mean-Element Messages\n", "\n", "Orbital Mean-Element Messages (OMMs) are standardized data products defined by CCSDS to exchange satellite orbital elements in a machine-readable way. They are growing in popularity and are now supported at https://www.celetrak.org and https://www.space-track.org.\n", "\n", "The standard is described at: https://ccsds.org/Pubs/502x0b3e1.pdf though neigher of the web pages above appear to adhere to it rigidly.\n", "\n", "OMMs can be encoded within:\n", "* JSON - very common and straightforward\n", "* XML - A bit more confusing, as there are more levels of heirarchy\n", "* KVN - Key-value notation, a terrible way for representing the data as it imposes very little structure\n", "\n", "`satkit` supports SGP4 propagation of OMMs represented as python dictionaries or lists of python dictionaries\n", "\n", "`satkit` does **not** support KVN\n" ] }, { "cell_type": "markdown", "id": "0c95f4a5", "metadata": {}, "source": [ "## Example 1\n", "\n", "The following example loads an OMM as json from https://www.celestrak.org , generates state vectors from the output, and converts the state vectors to geodetic positions" ] }, { "cell_type": "code", "execution_count": null, "id": "b0142e6f", "metadata": {}, "outputs": [], "source": [ "import satkit as sk\n", "import json\n", "import requests\n", "\n", "# Query the current ephemeris for the International Space Station (ISS)\n", "url = 'https://celestrak.org/NORAD/elements/gp.php?CATNR=25544&FORMAT=json'\n", "with requests.get(url) as response:\n", " omm = response.json()\n", "\n", "# Get a representative time from the output\n", "epoch = sk.time(omm[0]['EPOCH'])\n", "# crate a list of times .. once every 10 minutes\n", "time_array = [epoch + sk.duration(minutes=i*10) for i in range(6)]\n", "\n", "# TEME (inertial) output from SGP4\n", "pTEME, _vTEME = sk.sgp4(omm[0], time_array)\n", "\n", "# Rotate to Earth-fixed\n", "pITRF = [sk.frametransform.qteme2itrf(t) * p for t, p in zip(time_array, pTEME)]\n", "\n", "# Geodetic coordinates of space station at given times\n", "coord = [sk.itrfcoord(x) for x in pITRF]\n" ] }, { "cell_type": "markdown", "id": "cb018d7d", "metadata": {}, "source": [ "## Example 2\n", "\n", "Same as example above, except OMM is in XML. Note the additional complexity in the hierarchy\n", "\n", "also, plot the ground track" ] }, { "cell_type": "code", "execution_count": null, "id": "8576cfcc", "metadata": {}, "outputs": [], "source": [ "import satkit as sk\n", "import xmltodict\n", "import requests\n", "import plotly.graph_objects as go\n", "import numpy as np\n", "\n", "# Query the current ephemeris for the International Space Station (ISS)\n", "url = 'https://celestrak.org/NORAD/elements/gp.php?CATNR=25544&FORMAT=xml'\n", "with requests.get(url) as response:\n", " omm = xmltodict.parse(response.text)\n", "\n", "# Navigate to the relevant part of the parsed XML\n", "# Ugghh, what a terrible structure\n", "omm = omm['ndm']['omm']['body']['segment']['data']\n", "\n", "\n", "# Get a representative time from the output\n", "epoch = sk.time(omm['meanElements']['EPOCH'])\n", "# crate a list of times .. once every 10 minutes\n", "time_array = [epoch + sk.duration(minutes=i) for i in range(97)]\n", "\n", "# TEME (inertial) output from SGP4\n", "pTEME, _vTEME = sk.sgp4(omm, time_array)\n", "\n", "# Rotate to Earth-fixed\n", "pITRF = [sk.frametransform.qteme2itrf(t) * p for t, p in zip(time_array, pTEME)]\n", "\n", "coord = [sk.itrfcoord(x) for x in pITRF]\n", "\n", "lat, lon, alt = zip(*[(c.latitude_deg, c.longitude_deg, c.altitude) for c in coord])\n", "\n", "fig = go.Figure()\n", "fig.add_trace(go.Scattergeo(lat=lat, lon=lon, mode='lines'))\n", "fig.update_layout(margin={\"r\":0,\"t\":40,\"l\":0,\"b\":0}, title='ISS Ground Track', geo=dict(showland=True, showcountries=True))\n", "fig.show()\n", "fig = go.Figure()\n", "fig.add_trace(go.Scatter(x=[t.datetime() for t in time_array], y=np.array(alt)/1e3, mode='lines'))\n", "fig.update_layout(yaxis_title='Altitude (km)', xaxis_title='Time', font=dict(size=14), title='ISS Altitude vs Time')\n", "fig.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.0" } }, "nbformat": 4, "nbformat_minor": 5 }